<?php

namespace SinoPHP\BbdBoss\Model;

use Upfor\UpforPHP\Model;

class InnerDomainBakRecord extends Model { 

    /**
     * 获取主记录列表
     * 
     * @param  array   $where      
     * @param  integer $pageNumber 
     * @param  integer $pageSize
     * @param  array   $orderBy 
     * @return array
     */
    public function getBakList($where = null, $orderBy = null, $pageNumber = null, $pageSize = null) {
        $this->db->table($this->getTableName())->field([
            'bak_record_id',
            'master_record_id',
            'inner_domain_id',
            'dnspod_id',
            'record_line_id',
            'record_line_name',
            'ip_id',
            'bak_record',
            'ip_status',
            'status',
            'monitor_status',
            'create_time',
        ]);

        $this->db->where($where);

        if ($orderBy) {
            $this->db->order($orderBy);
        }

        if ($pageSize && $pageNumber) {
            $this->db->page($pageNumber, $pageSize);
        }

        return $this->db->getList();
    }

    /**
     * 获取备记录信息
     * 
     * @param  array $where
     * @return array
     */
    public function getBakInfo($where) {
        $field = [
            'bak_record_id',
            'master_record_id',
            'inner_domain_id',
            'dnspod_id',
            'record_line_id',
            'record_line_name',
            'ip_id',
            'bak_record',
            'ip_status',
            'status',
            'monitor_status',
        ];
        return $this->getRow($field, $where);
    }
}
